<div>
    If the body throws an exception, mark the build as a failure, but nonetheless
    continue to execute the Pipeline from the statement following the <code>catchError</code> step.
    The behavior of the step when an exception is thrown can be configured to print
    a message, set a build result other than failure, change the stage result,
    or ignore certain kinds of exceptions that are used to interrupt the build.
    <p>This step is most useful when used in Declarative Pipeline or with the
    options to set the stage result or ignore build interruptions. Otherwise,
    consider using plain <code>try</code>-<code>catch</code>(-<code>finally</code>) blocks.
    It is also useful when using certain post-build actions (notifiers)
    originally defined for freestyle projects which pay attention to the result of the ongoing build.
<p><pre>
node {
    catchError {
        sh 'might fail'
    }
    step([$class: 'Mailer', recipients: 'admin@somewhere'])
}
</pre>
    <p>If the shell step fails, the Pipeline build’s status will be set to failed, so that the subsequent mail step will see that this build is failed.
    In the case of the mail sender, this means that it will send mail.
    (It may also send mail if this build <em>succeeded</em> but previous ones failed, and so on.)
    Even in that case, this step can be replaced by the following idiom:
<p><pre>
node {
    try {
        sh 'might fail'
    } catch (err) {
        echo "Caught: ${err}"
        currentBuild.result = 'FAILURE'
    }
    step([$class: 'Mailer', recipients: 'admin@somewhere'])
}
</pre>
    <p>For other cases, plain <code>try</code>-<code>catch</code>(-<code>finally</code>) blocks may be used:
<p><pre>
node {
    sh './set-up.sh'
    try {
        sh 'might fail'
        echo 'Succeeded!'
    } catch (err) {
        echo "Failed: ${err}"
    } finally {
        sh './tear-down.sh'
    }
    echo 'Printed whether above succeeded or failed.'
}
// …and the pipeline as a whole succeeds
</pre>
    <p>See <a href="https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/master/CORE-STEPS.md#interacting-with-build-status" target="_blank">this document</a> for background.
</div>
